package com.api.shopapi.mapper;


import com.api.shopapi.entity.VerificationCodeLimit;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface VerificationCodeLimitMapper {

    @Insert("insert into verification_code_limit value" +
            "(" +
            "#{verificationCodeLimit.VerificationCodeLimitCode}," +
            "#{verificationCodeLimit.Ip}," +
            "#{verificationCodeLimit.Count}," +
            "#{verificationCodeLimit.CreateTime}" +
            ")")
    public int insert(@Param("verificationCodeLimit") VerificationCodeLimit verificationCodeLimit);

    @Delete("delete from verification_code_limit where VerificationCodeLimitCode=#{verificationCodeLimitCode}")
    public int delete(@Param("verificationCodeLimitCode") String verificationCodeLimitCode);

    @Update("update verification_code_limit set " +
            "Count = #{verificationCodeLimit.Count}," +
            "Ip = #{verificationCodeLimit.Ip}, "+
            "CreateTime = #{verificationCodeLimit.CreateTime}" +
            " where VerificationCodeLimitCode=#{verificationCodeLimit.VerificationCodeLimitCode}")
    public int update(@Param("verificationCodeLimit") VerificationCodeLimit verificationCodeLimit);

    @Select("select * from verification_code_limit order by CreateTime desc")
    public List<VerificationCodeLimit> getList();

    @Select("select * from verification_code_limit where VerificationCodeLimitCode=#{verificationCodeLimitCode} limit 1")
    public VerificationCodeLimit getByVerificationCodeLimitCode(@Param("verificationCodeLimitCode") String verificationCodeLimitCode);

    @Select("select * from verification_code_limit where iP=#{iP} limit 1")
    public VerificationCodeLimit getByIP(@Param("iP") String iP);


}
